package gunfire.events;

import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.curses.CurseOfTheBell;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.events.AbstractImageEvent;
import com.megacrit.cardcrawl.helpers.CardLibrary;
import com.megacrit.cardcrawl.localization.EventStrings;
import com.megacrit.cardcrawl.vfx.cardManip.ShowCardAndObtainEffect;
import gunfire.GunfireMod;
import gunfire.relics.SoulOfTaizi;

import java.util.Random;

import static gunfire.GunfireMod.makeEventPath;

public class RedChestEvent3 extends AbstractImageEvent {
    public static final String ID = GunfireMod.makeID("RedChestEvent3");
    private static final EventStrings eventStrings = CardCrawlGame.languagePack.getEventString(ID);
    private static final String NAME = eventStrings.NAME;
    private static final String[] DESCRIPTIONS = eventStrings.DESCRIPTIONS;
    private static final String[] OPTIONS = eventStrings.OPTIONS;
    public static final String IMG = makeEventPath("RedChest.png");
    private int screenNum;
    private Random r;

    public RedChestEvent3() {
        super(NAME, DESCRIPTIONS[0], IMG);
        this.imageEventText.setDialogOption(OPTIONS[0], CardLibrary.getCopy("CurseOfTheBell"));
        this.imageEventText.setDialogOption(OPTIONS[1]);
        this.screenNum = 0;
        this.r = new Random();
    }

    @Override
    protected void buttonEffect(int i) {
        if(this.screenNum == 0){
            if(i == 0){
                SoulOfTaizi r = new SoulOfTaizi();
                AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2), r);
                AbstractCard c1 = new CurseOfTheBell();
                AbstractCard c2 = new CurseOfTheBell();
                AbstractCard c3 = new CurseOfTheBell();
                AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c1, (float)Settings.WIDTH / 2.0F + this.r.nextInt(200), (float)Settings.HEIGHT / 2.0F + this.r.nextInt(200)));
                AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c2, (float)Settings.WIDTH / 2.0F, (float)Settings.HEIGHT / 2.0F));
                AbstractDungeon.effectList.add(new ShowCardAndObtainEffect(c3, (float)Settings.WIDTH / 2.0F - this.r.nextInt(200), (float)Settings.HEIGHT / 2.0F - this.r.nextInt(200)));
            } else {
                this.openMap();
            }
            this.imageEventText.clearAllDialogs();
            this.imageEventText.setDialogOption(OPTIONS[1]);
            this.screenNum++;
        } else {
            this.openMap();
        }
    }
}
